package cn.example.vip.mall.permission.service.impl;

import cn.example.vip.mall.permission.entity.Permission;
import cn.example.vip.mall.permission.mapper.PermissionMapper;
import cn.example.vip.mall.permission.service.PermissionService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permission> implements PermissionService {
	@Autowired
	private PermissionMapper permissionMapper;
	
	/**
	 * 查询匹配方式
	 * @param matchMethod
	 * @return
	 */
	@Override
	public List<Permission> findByMatch(Integer matchMethod) {
		QueryWrapper<Permission> queryWrapper = new QueryWrapper<>();
		queryWrapper.eq("url_match", matchMethod);
		return permissionMapper.selectList(queryWrapper);
	}
	
	@Override
	public List<Map<Integer, Integer>> allRolePermission() {
		return permissionMapper.allRolePermission();
	}
}
